﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HP.Cachalote.Repositories.NHibernate;
using HP.Cachalote.Repositories.Interfaces;
using HP.Cachalote.Services.Interfaces;

namespace HP.Cachalote.Services
{
    /// <summary>
    /// A factory class that manage every single service.
    /// </summary>
    public class ServiceFactory : IServiceFactory
    {
        protected IRepositoryFactory RepositoryFactory;

        /// <summary>
        /// The basic version of Dependency Injection.
        /// </summary>
        /// <param name="repositoryFactory">An instance implements IRepositoryFactory.</param>
        public ServiceFactory(IRepositoryFactory repositoryFactory)
        {
            RepositoryFactory = repositoryFactory;
        }

        public ServiceFactory() : this(new RepositoryFactory()) { }

        /// <summary>
        /// Create an instance of LabelService to do any related business logic.
        /// </summary>
        /// <returns>An instance of LabelService</returns>
        public ITodoLabelService CreateLabelService()
        {
            return new TodoLabelService(RepositoryFactory);
        }

        /// <summary>
        /// Create an instance of TodoItemService to do any related business logic.
        /// </summary>
        /// <returns>An instance of TodoItemService</returns>
        public ITodoItemService CreateTodoItemService()
        {
            return new TodoItemService(RepositoryFactory);
        }
    }
}
